use actix_web::{get, HttpResponse, Responder, web};
use crate::model::User;
use crate::response::HttpResult;

#[get("/user_list")]
async fn get_user_list() -> impl Responder {
    let u = User { username: "uuicon".to_string(), password: "1233".to_string() };
    let u2 = User { username: "creator".to_string(), password: "23222".to_string() };
    let v_list = vec![u, u2];
    HttpResponse::Ok().json(&HttpResult {
        flag: true,
        code: 20000,
        message: "请求数据成功!".to_string(),
        data: v_list,
    })
}

pub fn config(conf: &mut web::ServiceConfig) {
    let scope = web::scope("/users")
        .service(get_user_list);
    conf.service(scope);
}